package spring.cloud.tasks.client.item_task_processor.task_item;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

public class ServerTaskItemContractExtensionInfo {
    @Setter
    @Getter
    private String processorId;
    @Setter
    @Getter
    private Date lastTimeExtensionDate = new Date();//最后一次的续约时间 为空或者超过时间则自动不处理

    public static ServerTaskItemContractExtensionInfo parse(String string) {
        return JSON.parseObject(string, ServerTaskItemContractExtensionInfo.class);
    }

    public static ServerTaskItemContractExtensionInfo parse(byte[] bytes) {
        return JSON.parseObject(new String(bytes), ServerTaskItemContractExtensionInfo.class);
    }

    public String getString() {
        return JSON.toJSONString(this);
    }

    public byte[] getBytes() {
        return JSON.toJSONString(this).getBytes();
    }

    public boolean isOverdue() {
        return lastTimeExtensionDate.before(new Date());
    }
}
